import mido

mid = mido.MidiFile("/storage/emulated/0/mymidi/tongJi.mid")
f = open("/storage/emulated/0/mymidi/myTongJi.txt", "w")

string = ""
for i, track in enumerate(mid.tracks):
    for msg in track:
        if not msg.is_meta:
            string += (str(vars(msg)) + ",\n")

f.write(string[:len(string)-2])
f.close()
